#include "enumtype.h"
#include <iostream>
using namespace std;

// 定义一个枚举
// 1、枚举值 -- 默认是从0开始计数的依次递增的整数。
enum colorenum{
    red,
    green,
    blue
};

enum colorenum1{
    black=1,yellow=3
};

enum colorenum2{
    brown=1,white
};

enum colorenum3{
    orange=1,purple=1
} backColor;

EnumType::EnumType()
{

}

void EnumType::show(){
    // 枚举的声明方式
    cout << "====================EnumType show===========================" << endl;
    cout << red << endl;
    cout << green << endl;

    colorenum color; //枚举的变量声明
    color = red;

    //
    int a;
    a = red;

    cout << "a:" << a << endl;
    cout << "black:" << black << endl;
    cout << "brown:" << brown << endl;
    cout << "white:" << white << endl;
    cout << "orange:" << orange << endl;

    // 定义一个枚举变量，同时赋值
    colorenum backColor1 = colorenum(1);
    colorenum backColor2 = colorenum(2);
    colorenum backColor3 = colorenum(3);
    cout << backColor1 << backColor2 << backColor3 << endl;

    for (colorenum color : {red,green,blue}){
        cout << color << endl;
    }

    switch (color) {
        case red: { cout << "color=red" << endl; break; }
        case green: { cout << "color=green" << endl; break; }
        case blue:{ cout << "color=blue" << endl; break; }
    }

    color = blue;
    if(color == red){
        cout << "color=red" << endl;
    }else if(color == green){
        cout << "color=green" << endl;
    }else if(color == blue){
        cout << "color=blue" << endl;
    }
}
